package com.dayu.demo.pojo;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
import java.math.BigDecimal;
import com.vecspace.data.model.RowMapper;
import com.vecspace.data.model.IdEntity;
import com.vecspace.dicttable.DictAll;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Transient;
import com.vecspace.data.model.IDataLockState;


/** 员工
 * @template dayu-code-builder
 * @author user
 * @reviewer 
 * @createTime 2021-11-24 15:11:41
 * @version 1.0
 */
@Entity
@Polymorphism(type = PolymorphismType.EXPLICIT)
@Table(name = "T_DEMO_EMPLOYEE")
public class Employee implements IdEntity, IDataLockState, java.io.Serializable {

    public Employee(){
    }
    
    private static final long serialVersionUID = 10017L;

    /** ID */
    private Long id;
    /** 所属部门 */
    private Long deptId;
    /** 姓名 */
    private String name;
    /** 证件类型 */
    private String idCardType;
    /** 身份证号 */
    private String idCardNumber;
    /** 性别 */
    private String sex;
    /** 出生日期 */
    private LocalDate birthday;
    /** 籍贯 */
    private String birthplace;
    /** 电话 */
    private String mobile;
    /** 邮箱 */
    private String email;
    /** 岗位 */
    private String jobTitle;
    /** 学历 */
    private String education;
    /** 毕业学校 */
    private String school;
    /** 专业 */
    private String speciality;
    /** 备注 */
    private String remarks;
    /** 顺序号 */
    private Integer ordnum;
    /** 租户ID */
    private Long tenantId;
    /** 锁定状态 */
    private Integer rowLock;
    /** 记录创建时间 */
    private LocalDateTime createTime;
    /** 记录创建人ID */
    private Long createUser;

    /**性别 字典码*/
    public static final String SexCode = "DM-DEMO-010";
    /**性别*/
    @Transient
    @Column(name = "SEX")
    public String getSexCaption(){
        return DictAll.getCachedItemName(SexCode, sex);
    }


/****************************** getter setter *******************************************/


    /**ID*/
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId(){
        return id;
    }

    /**ID*/
    public void setId(Long value){
        this.id = value;
    }

    /**所属部门*/
    @Column(name = "DEPT_ID")
    public Long getDeptId(){
        return deptId;
    }

    /**所属部门*/
    public void setDeptId(Long value){
        this.deptId = value;
    }

    /**姓名*/
    @Column(name = "NAME_")
    public String getName(){
        return name;
    }

    /**姓名*/
    public void setName(String value){
        this.name = value;
    }

    /**证件类型*/
    @Column(name = "ID_CARD_TYPE")
    public String getIdCardType(){
        return idCardType;
    }

    /**证件类型*/
    public void setIdCardType(String value){
        this.idCardType = value;
    }

    /**身份证号*/
    @Column(name = "ID_CARD_NUMBER")
    public String getIdCardNumber(){
        return idCardNumber;
    }

    /**身份证号*/
    public void setIdCardNumber(String value){
        this.idCardNumber = value;
    }

    /**性别*/
    @Column(name = "SEX")
    public String getSex(){
        return sex;
    }

    /**性别*/
    public void setSex(String value){
        this.sex = value;
    }

    /**出生日期*/
    @Column(name = "BIRTHDAY")
    public LocalDate getBirthday(){
        return birthday;
    }

    /**出生日期*/
    public void setBirthday(LocalDate value){
        this.birthday = value;
    }

    /**籍贯*/
    @Column(name = "BIRTHPLACE")
    public String getBirthplace(){
        return birthplace;
    }

    /**籍贯*/
    public void setBirthplace(String value){
        this.birthplace = value;
    }

    /**电话*/
    @Column(name = "MOBILE")
    public String getMobile(){
        return mobile;
    }

    /**电话*/
    public void setMobile(String value){
        this.mobile = value;
    }

    /**邮箱*/
    @Column(name = "EMAIL")
    public String getEmail(){
        return email;
    }

    /**邮箱*/
    public void setEmail(String value){
        this.email = value;
    }

    /**岗位*/
    @Column(name = "JOB_TITLE")
    public String getJobTitle(){
        return jobTitle;
    }

    /**岗位*/
    public void setJobTitle(String value){
        this.jobTitle = value;
    }

    /**学历*/
    @Column(name = "EDUCATION")
    public String getEducation(){
        return education;
    }

    /**学历*/
    public void setEducation(String value){
        this.education = value;
    }

    /**毕业学校*/
    @Column(name = "SCHOOL_")
    public String getSchool(){
        return school;
    }

    /**毕业学校*/
    public void setSchool(String value){
        this.school = value;
    }

    /**专业*/
    @Column(name = "SPECIALITY")
    public String getSpeciality(){
        return speciality;
    }

    /**专业*/
    public void setSpeciality(String value){
        this.speciality = value;
    }

    /**备注*/
    @Column(name = "REMARKS")
    public String getRemarks(){
        return remarks;
    }

    /**备注*/
    public void setRemarks(String value){
        this.remarks = value;
    }

    /**顺序号*/
    @Column(name = "ORDNUM")
    public Integer getOrdnum(){
        return ordnum;
    }

    /**顺序号*/
    public void setOrdnum(Integer value){
        this.ordnum = value;
    }

    /**租户ID*/
    @JsonIgnore(true)
    @Column(name = "TENANT_ID")
    public Long getTenantId(){
        return tenantId;
    }

    /**租户ID*/
    public void setTenantId(Long value){
        this.tenantId = value;
    }

    /**锁定状态*/
    @Column(name = "ROW_LOCK")
    public Integer getRowLock(){
        return rowLock;
    }

    /**锁定状态*/
    public void setRowLock(Integer value){
        this.rowLock = value;
    }

    /**记录创建时间*/
    @JsonIgnore(true)
    @Column(name = "CREATE_TIME")
    public LocalDateTime getCreateTime(){
        return createTime;
    }

    /**记录创建时间*/
    public void setCreateTime(LocalDateTime value){
        this.createTime = value;
    }

    /**记录创建人ID*/
    @JsonIgnore(true)
    @Column(name = "CREATE_USER")
    public Long getCreateUser(){
        return createUser;
    }

    /**记录创建人ID*/
    public void setCreateUser(Long value){
        this.createUser = value;
    }

    public void parseFrom(Map<String, Object> row){
        RowMapper rowMapper = new RowMapper(row);
        this.id = rowMapper.getLong("ID");
        this.deptId = rowMapper.getLong("DEPT_ID");
        this.name = rowMapper.getString("NAME_");
        this.idCardType = rowMapper.getString("ID_CARD_TYPE");
        this.idCardNumber = rowMapper.getString("ID_CARD_NUMBER");
        this.sex = rowMapper.getString("SEX");
        this.birthday = rowMapper.getLocalDate("BIRTHDAY");
        this.birthplace = rowMapper.getString("BIRTHPLACE");
        this.mobile = rowMapper.getString("MOBILE");
        this.email = rowMapper.getString("EMAIL");
        this.jobTitle = rowMapper.getString("JOB_TITLE");
        this.education = rowMapper.getString("EDUCATION");
        this.school = rowMapper.getString("SCHOOL_");
        this.speciality = rowMapper.getString("SPECIALITY");
        this.remarks = rowMapper.getString("REMARKS");
        this.ordnum = rowMapper.getInteger("ORDNUM");
        this.tenantId = rowMapper.getLong("TENANT_ID");
        this.rowLock = rowMapper.getInteger("ROW_LOCK");
        this.createTime = rowMapper.getLocalDateTime("CREATE_TIME");
        this.createUser = rowMapper.getLong("CREATE_USER");
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null)return false;
        if(id == null)return false;
        Employee other = (Employee)obj;
        return id.equals(other.id);
    }

    @Override
    public int hashCode() {
        if(id == null)return 0;
        return id.hashCode();
    }
}
